<template>
	<u-popup :show="uShow" mode="center"  @close="close"  :round="10" :closeable="true" :closeOnClickOverlay="false">
		<view class="title">原密码</view>
		<u-code-input v-model="oldPassword" :maxlength="6" dot :size="80" :focus="true"></u-code-input>
		<view class="title">新密码</view>
		<u-code-input v-model="newPassword" :maxlength="6" dot :size="80"></u-code-input>
		<view class="title">再次确认</view>
		<u-code-input v-model="confirmPassword" :maxlength="6" dot :size="80" @finish="sumbit"></u-code-input>
	</u-popup>
</template>

<script>
	export default{
		data(){
			return {
				newPassword:'',
				confirmPassword:'',
				oldPassword:''
			}
		},
		props:{
			uShow:{
				type:Boolean,
				default:false
			},
			isSetPaw:{
				type:Boolean,
				default:false
			},
		},
		onLoad(){},
		methods:{
			close(){
				this.$emit('hide')
				this.newPassword = ''
				this.confirmPassword = ''
				this.oldPassword = ''
			},
			//输入密码之后
			sumbit(){
				if(this.newPassword !== this.confirmPassword){
					uni.showToast({
						title: '两次密码不一致，请重新输入！',
						icon: 'none',
					})
				}else{
					let params = {
						iccid: uni.getStorageSync('iccid') || '',
						paypassOld: this.oldpaw,
						paypass: this.newpaw,
					};
					this.$api.resetPaypass(params).then(res=>{
						if(res.code === '200'){
							uni.showToast({
								title: '密码设置成功',
								icon: 'none',
							})
							this.close()
						}else{
							uni.showToast({
								title: res.message,
								icon: 'none',
							})
						}
					})
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	::v-deep .u-transition{
		justify-content: normal !important;
	}
	::v-deep .u-popup__content{
		width:80%;
		top: 30%;
		padding:30upx;
		.massage{
			color: #646668;
			font-size: 28upx;
		}
		.btn-flex{
			flex-direction: row;
			margin-top:40upx;
			.u-button{
				width:45%;
				height:100upx;
			}
		}
		.title{
			margin-bottom:40upx;
			font-size:36upx;
		}
		.u-code-input{
			margin-left: 20px;
			margin-bottom: 20px;
		}
	}
</style>